package cn.bitkit.tools.file;

import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class TextHelper {
	
	private String text = "";
	
	public static TextHelper loadFile(String file) {
		return loadString(FileUtil.readAsString(file));
	}

	public static TextHelper loadString(String text) {
		TextHelper builder = new TextHelper();
		builder.setText(text);
		return builder;
	}
	
	public TextHelper setValue(String key, String val) {
		if (val == null){
			val = "";
		}
		this.text = this.text.replaceAll("\\$\\{"+key+ "}", val);
		return this;
	}


}
